home *** CD-ROM | disk | FTP | other *** search
- Path: lrz-muenchen.de!news
- From: watzka@stat.uni-muenchen.de (Kurt Watzka)
- Newsgroups: comp.lang.c
- Subject: Re: symbol type at runtime
- Date: 21 Mar 1996 15:50:12 GMT
- Organization: Leibniz-Rechenzentrum, Muenchen (Germany)
- Distribution: world
- Message-ID: <4irtrk$2vn@sparcserver.lrz-muenchen.de>
- References: <Pine.OSF.3.91.960320170224.19850A-100000@krtkg1.rug.ac.be>
- NNTP-Posting-Host: sun2.lrz-muenchen.de
-
- Christophe Colle <colle@krtkg1.rug.ac.be> writes:
-
- >Hi all,
-
- >I wonder if there is a way to find out the type of a variable at runtime,
- >without using tricks like #define etc.
-
- >eg:
-
- >char array[10];
-
- >int function(int blah, char *ptr)
- >{
- > /* in this function i want to find the exact type of the variabl which
- > is passed in ptr. I want to find a char array[10] and not char *
- > when called with function(blah, array);
- > /*
-
- Since the type of "ptr" _is_ pointer to char and _not_ array of 10 chars,
- you _don't_ want to find the type of "ptr", you want to find something
- different. Consider the following call to function:
-
- char *p = malloc(n);
- if (p) {
- /* Initialize p */
- function(bleh, p);
- }
-
- What should your "type detection" do in this situation? If you want
- to know the length of a vector passed to a C function, you have to
- pass that length to the function.
-
- Kurt
- --
- | Kurt Watzka Phone : +49-89-2180-6254
- | watzka@stat.uni-muenchen.de
- | ua302aa@sunmail.lrz-muenchen.de
-
-